﻿using System;
using System.Globalization;
using Kiva7.Images;
using Kiva7.Translations;
using Microsoft.Phone.Controls;

namespace Kiva7.Pages
{
    public partial class HelpPage
    {
        private const string Url = "/Pages/HelpPage.xaml";
        public readonly static Uri PageUrl = new Uri(Url, UriKind.RelativeOrAbsolute);

        private CultureInfo _culture;

        public HelpPage()
        {
            InitializeComponent();
            CreateStandardControls();
            _culture = new CultureInfo("en");
            SetTranslations();
        }

        protected override void CreateApplicationBar()
        {
            AddBarButton(AppResources.TranslateTexts, ImageUrls.Translation, TranslateClick);
        }

        private void TranslateClick(object sender, EventArgs e)
        {
            if (_culture == null)
            {
                _culture = new CultureInfo("en");
            }
            else
            {
                _culture = null;
            }
            SetTranslations();
        }

        private  void SetTranslations()
        {
            HelpResources hr = new HelpResources(_culture);
            HA1.Text = hr.HA1;
            HA2.Text = hr.HA2;
            HA3.Text = hr.HA3;
            HA4.Text = hr.HA4;
            HA5.Text = hr.HA5;
            HA6.Text = hr.HA6;
            HA7.Text = hr.HA7;
            HA8.Text = hr.HA8;
            HA9.Text = hr.HA9;

            KW01.Text = hr.KW01;
            KW02.Text = hr.KW02;
            KW03.Text = hr.KW03;
            KW04.Text = hr.KW04;
            KW05.Text = hr.KW05;
            KW06.Text = hr.KW06;
            KW07.Text = hr.KW07;
            KW08.Text = hr.KW08;
            KW09.Text = hr.KW09;
            KW10A.Text = hr.KW10A;
            KW10B.Text = hr.KW10B;
            KW11.Text = hr.KW11;
            KW12.Text = hr.KW12;
        }

        private void PivotLoadingPivotItem(object sender, PivotItemEventArgs e)
        {
            BindableApplicationBar.IsVisible = e.Item != pvVideos;
        }

    }
}